
from flask import Flask, request
from flask_sqlalchemy import SQLAlchemy
from app import mysql



class Note(mysql.Model):
    __tablename__ = 'book_note'

    note_id = mysql.Column(mysql.Integer, primary_key=True)
    user_id = mysql.Column(mysql.String(10))
    # book_id = mysql.Column(mysql.String(10))
    isbn = mysql.Column(mysql.String(10))
    title = mysql.Column(mysql.String(20))
    content = mysql.Column(mysql.Text)
    publish_date = mysql.Column(mysql.Date)
    like_count = mysql.Column(mysql.Integer)
    collect_count = mysql.Column(mysql.Integer)
    transmit_count = mysql.Column(mysql.Integer)


    def __init__(self,user_id,isbn,title,content,publish_date,like_count,collect_count,transmit_count ):
        self.user_id =user_id;
        # self.book_id =book_id;
        self.isbn =isbn;
        self.title =title;
        self.content =content;
        self.publish_date =publish_date;
        self.like_count =like_count;
        self.collect_count =collect_count;
        self.transmit_count =transmit_count;
        super().__init__()

    def __repr__(self):
        return f'<Note note_id = {self.note_id} user_id = {self.user_id}  isbn = {self.isbn} title = {self.title} content = {self.content} publish_date = {self.publish_date} like_count = {self.like_count} collect_count = {self.collect_count} transmit_count = {self.transmit_count}>'

class Like_by(mysql.Model):
        __tablename__ = 'like_by'  # 指定表名
        by_id = mysql.Column(mysql.Integer, primary_key=True)
        note_id = mysql.Column(mysql.String(10))
        like_id = mysql.Column(mysql.String(10))

def __init__(self, note_id, like_id):
            self.note_id = note_id
            self.like_id = like_id
            super().__init__()

def __repr__(self):
            return f'<Like_by note_id={self.note_id} like_id={self.like_id}>'

class Collect_by(mysql.Model):
            __tablename__ = 'collect_by'  # 指定表名
            by_id = mysql.Column(mysql.Integer, primary_key=True)
            note_id = mysql.Column(mysql.String(10))
            collect_id = mysql.Column(mysql.String(10))

def __init__(self, note_id, collect_id):
                self.note_id = note_id
                self.collect_id = collect_id
                super().__init__()

def __repr__(self):
                return f'<Collect_by note_id={self.note_id} collect_id={self.collect_id}>'